#include <iostream>
using namespace std;

int main()
{
    int n = 0, count = 0;
    cin >> n;
    

    for (int i = 0; i <= n; i++)
    {
        if (i == 0 || i == 1)
        {
            count++;
            continue;
        }
        if (i == 2 || i == 3)
        {
            continue;
        }
        int N = i * i;
        int tmp = i;
        int digits = 1;
        while (tmp)
        {
            tmp /= 10;
            digits *= 10;
        }
        if (N % digits == i)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}
